﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MainTemplate.Master" AutoEventWireup="true" CodeBehind="AdminUser.aspx.cs" Inherits="Enterprise.Admin.AdminUser" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table id="admin_user"></table>
    <div id="admin_user_detail_dialog">
        <table id="admin_user_detail"></table>
    </div>
    <div id="admin_user_modify_password">
        <form id="modify_password_form" action="AdminUser.aspx" method="post">
            <input type="hidden" name="CoAdminId" id="admin_user_id" value="" />
            <p>
                <label>用户名:</label><u id="admin_user_name"></u>
            </p>
            <p>
                <label>原密码:</label>
                <input type="password" name="oldpassword" id="oldpassword" class="easyui-validatebox input_password" required="true" validtype="length[5,20]" missingmessage="请输入原密码" invalidmessage="密码长度必须在5-20字符之间" />
            </p>
            <p>
                <label>新密码:</label>
                <input type="password" name="newpassword" id="newpassword" class="easyui-validatebox input_password" validtype="length[5,20]" required="true" missingmessage="请输入新密码" invalidmessage="密码长度必须在5-20字符之间" />
            </p>
            <p>
                <label>确认密码:</label>
                <input type="password" name="confirmpassword" id="confirmpassword" class="easyui-validatebox input_password" validtype="equalTo['#newpassword']" required="true" missingmessage="请再次输入密码" invalidmessage="确认密码不匹配" />
            </p>
        </form>
    </div>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            $("#admin_user").datagrid({
                title: "管理员列表",
                pagination: true,
                fitColumns: true,
                url: "Handle/GetAdminUserListJson.aspx",
                onClickRow: function (rowIndex) {
                    $(this).datagrid('unselectRow', rowIndex);
                },
                columns: [[
                    { field: 'CoAdminId', title: '选中', width: 80, align: 'center', checkbox: true },
                    { field: 'CoUserName', title: '用户名', width: 280, align: 'center' },
                    {
                        field: 'ChangePassword', title: '修改密码', width: 60, align: 'center', formatter: function (value, rec) {
                            return '<a href="javascript:void(0);" mce_href="#" onclick="changePassword(\'' + rec.CoAdminId + '\',\'' + rec.CoUserName + '\')">修改</a> ';
                        }
                    },
                {
                    field: 'Detail', title: '查看', width: 60, align: 'center', formatter: function (value, rec) {
                        return '<a href="javascript:void(0);" mce_href="#" onclick="view(\'' + rec.CoAdminId + '\')">查看</a> ';
                    }
                }
                ]]
            });
            $('#admin_user_modify_password').dialog({
                width: 400,
                height: 250,
                title: '管理员密码修改',
                closed: true,
                closable: true,
                tools: [{
                    iconCls: 'icon-save',
                    handler: function () {
                        modifyPasswordSave();
                    }
                }],
                buttons: [{
                    text: '保存',
                    iconCls: 'icon-ok',
                    handler: function () {
                        modifyPasswordSave();
                    }
                }, {
                    text: '关闭',
                    handler: function () {
                        $('#admin_user_modify_password').dialog('close');
                    }
                }]
            });
            $('#admin_user_detail_dialog').dialog({
                width: '600',
                height: '400',
                title: '管理员详细信息',
                closed: true,
                closable: true,
                buttons: [{
                    text: '关闭',
                    handler: function () {
                        $('#admin_user_detail_dialog').dialog('close');
                    }
                }]
            });
        });
        function view(id) {
            $('#admin_user_detail').propertygrid({
                fit: true,
                url: 'Handle/GetAdminUserDetailJson.aspx?id=' + id,
                showGroup: false,
                showHeader: false,
                closable: true,
                loadMsg: '正在处理,请稍等...'
            });
            $('#admin_user_detail_dialog').dialog("open");
        }
        function changePassword(id, userName) {
            $('#modify_password_form')[0].reset();
            $('#admin_user_modify_password').dialog("open");
            $("#admin_user_id").val(id);
            $("#admin_user_name").html(userName);
        }
        function modifyPasswordSave() {
            if ($("#modify_password_form").form("validate"))
                $.ajax({
                    type: "POST",
                    url: "Handle/ModifyPassword.aspx",
                    data: $("#modify_password_form").serialize(),
                    success: function (msg) {
                        $.messager.alert('提示', msg.message, "info");
                    },
                    error: function () {
                        $.messager.alert('提示', '修改失败！', "error");
                    }
                });
        }
    </script>
</asp:Content>
